FROM alpine:3.2

ENV SSH_URL="" SSH_PORT=22 SSH_PASSWORD=""

RUN apk add --update && apk add openssh-client sshpass supervisor && rm -rf /var/cache/apk/*

RUN echo "[program:sshpass]" >> /etc/supervisord.conf
RUN echo "autostart=true" >> /etc/supervisord.conf
RUN echo "autorestart=true" >> /etc/supervisord.conf
RUN echo "command=/usr/bin/sshpass -p \$SSH_PASSWORD /usr/bin/ssh -D 0.0.0.0:3128 -o 'StrictHostKeyChecking no' $SSH_URL -p \$SSH_PORT" >> /etc/supervisord.conf

CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]